#include <cv.h>
#include <highgui.h>

#include "resourceTracker.h"


//this looks up the location of the gtest files in header hiDependenciesForTestFramework.h
//TODO : Design choice? currently I'll keep this dependency in a very specific header file
// as changing it should cause minimal recompilation.

#include "hiDependenciesForTestFramework.h"
#include HI_DEPENDENCY_GTEST_HEADER

using namespace cv;

namespace {
	
	// The fixture for testing class ResourceTracker.
	class ResourceTrackerTest : public ::testing::Test {
	public:
		
		ResourceTracker* rt;
	
		virtual void SetUp() {
			try {
				rt = new ResourceTracker( "../config/runtimeSettings/cfg.xml" ); //TODO even later binding?
				rt->loadCategory("TestData");
			}
			catch (cv::Exception& e) {
				ASSERT_TRUE(false); //Test failed!
			}
		}
		
//		virtual void TearDown() {
//			// Code here will be called immediately after each test (right
//			// before the destructor).
//		}
//		
//		// Objects declared here can be used by all tests in the test case.
	};
	
	
	TEST_F(ResourceTrackerTest,loadCategoryDoesNotBreak ) {
		//Just testing setup!
	}
	
	TEST_F(ResourceTrackerTest,getMatLoadsImage) {
		try {
			Mat testImg = rt->getMat("facetest1");
		}
		catch (cv::Exception& e) {
			ASSERT_TRUE(false); //Test failed!
		}
	}
	
	TEST_F(ResourceTrackerTest,getPointGetsPoint) {
		try {
			Point p = rt->getPointTag("facetest1");
			
			//check that correct tag was found
			ASSERT_TRUE( p.x == 125 && p.y == 399);
		}
		catch (cv::Exception& e) {
			ASSERT_TRUE(false); //Test failed!
		}
	}
	
}  // namespace

//NOT needed: instead, should link with gtest_main.a
//int main(int argc, char **argv) {
//	::testing::InitGoogleTest(&argc, argv);
//	return RUN_ALL_TESTS();
//}